package com.demo.gateway.filter;

import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.gateway.filter.GatewayFilterChain;
import org.springframework.cloud.gateway.filter.GlobalFilter;
import org.springframework.core.Ordered;
import org.springframework.stereotype.Service;
import org.springframework.web.server.ServerWebExchange;
import reactor.core.publisher.Mono;

/**
 *
 * @author
 * @since
 */
@Service
@Slf4j
public class GpDefineFilter implements GlobalFilter, Ordered {
  @Override
  public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {
    log.info("[pre]-Enter GpDefineFilter");
    return chain.filter(exchange).then(Mono.fromRunnable(() -> {
      log.info("[Post]-Return GpDefineFilter");
    }));
  }

  @Override
  public int getOrder() {
    return -10;
  }
}
